//
//  ViewController.m
//  基于AFNetWorking的再封装
//
//  Created by 吴红星 on 16/1/2.
//  Copyright © 2016年 wuhongxing. All rights reserved.
//

#import "ViewController.h"
#import "HttpRequest.h"

@interface ViewController () 

@end

@implementation ViewController

#pragma mark - 三种请求的使用方法
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    //get请求
    /*
    [HttpRequest getWithURLString:@"http://1000phone.net:8088/app/iAppFree/api/limited.php?page=1&number=20" parameters:nil success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        NSLog(@"%@",json);
    } failure:^(NSError *error) {
        NSLog(@"请求失败");
    }];
     */
    

    //post请求
    /*
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    params[@"page"] = @"1";
    params[@"number"] = @"20";
    [HttpRequest postWithURLString:@"http://1000phone.net:8088/app/iAppFree/api/limited.php" parameters:params success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        NSLog(@"--------------------%@",json);
    } failure:^(NSError *error) {
        NSLog(@"--------------------请求失败");
    }];
     */
    
    //2合1
    UIImageView *iamgeV = [[UIImageView alloc] init];
    iamgeV.frame = [UIScreen mainScreen].bounds;
    [self.view addSubview:iamgeV];
    [[HttpRequest sharedInstance] requestWithURLString:@"http://b.hiphotos.baidu.com/zhidao/wh%3D600%2C800/sign=abb1ea66bb12c8fcb4a6fecbcc33be7d/4ec2d5628535e5dd3e2b3d9974c6a7efce1b6275.jpg" parameters:nil type:HttpRequestTypeGet success:^(id responseObject) {
        iamgeV.image = [UIImage imageWithData:responseObject];
    } failure:^(NSError *error) {
        NSLog(@"请求错误");
    }];
    
    
}




@end
